<?php
class App_Plugin_FlashMessages extends Zend_Controller_Plugin_Abstract
{

    public function preDispatch(Zend_Controller_Request_Abstract $request){


    	$actionHelperFlashMessenger = new Zend_Controller_Action_Helper_FlashMessenger();



        $messagesSuccess = $actionHelperFlashMessenger->getMessages();
      //  die;

        $actionHelperFlashMessenger->clearMessages();

        if (empty($messagesSuccess)) {
			return;
		}

        $layout = Zend_Layout::getMvcInstance();

		$view = $layout->getView();
		$view->messages = $messagesSuccess;
    }
//


	public function postDispatch(Zend_Controller_Request_Abstract $request)
	{

//		$actionHelperFlashMessenger = new Zend_Controller_Action_Helper_FlashMessenger();
//		$messagesSuccess = $actionHelperFlashMessenger->getCurrentMessages();
//		$actionHelperFlashMessenger->clearCurrentMessages();
//		if (empty($messagesSuccess) || !$request->isDispatched()) {
//			return;
//		}
//		$this->getResponse()->append('body', 'aa');

		//$view = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view;

//		strip_tags($str);

//		$layout = Zend_Layout::getMvcInstance();
//		$view = $layout->getView();
//		/$view->messages = $messagesSuccess;


//		$view->a = 777;
		//$layout = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view;
   		//$layout->assign('a', 1);


//		print_r($request);

	}

}
